package com.ostrich.module_player.adapter

import com.chad.library.adapter.base.BaseProviderMultiAdapter
import com.ostrich.module_player.R
import com.ostrich.module_player.adapter.provider.*
import com.ostrich.module_player.entity.PlayerEntity

/**
 * @Author : yaotianxue
 * @Time : On 2023/11/3 14:39
 * @Description : PlayerAdapter
 */
class PlayerAdapter:BaseProviderMultiAdapter<PlayerEntity>() {
    init {
        addItemProvider(TextCardProvider(PlayerItemType.TEXT_CARD_VIEW, R.layout.player_item_title_white_view))
        addItemProvider(VideoSmallCardProvider(PlayerItemType.VIDEO_CARD_VIEW, R.layout.player_item_video_card_white_view))
        addItemProvider(LeftAlignTextHeaderProvider(PlayerItemType.LEFT_TITLE_VIEW, R.layout.player_item_comment_title_white_view))
        addItemProvider(ReplyProvider(PlayerItemType.REPLY_CARD_VIEW, R.layout.player_item_reply_view))
        addItemProvider(EmptyProvider(PlayerItemType.EMPTY_VIEW, R.layout.player_item_empty))

    }


    override fun getItemType(data: List<PlayerEntity>, position: Int): Int {
        return when(data[position].type){
            "textCard" -> PlayerItemType.TEXT_CARD_VIEW
            "videoSmallCard" -> PlayerItemType.VIDEO_CARD_VIEW
            "leftAlignTextHeader" ->PlayerItemType.LEFT_TITLE_VIEW
            "reply" -> PlayerItemType.REPLY_CARD_VIEW
            else -> PlayerItemType.EMPTY_VIEW



        }
    }
}